$(function ()
{
    findById();
})

function findById()
{
    let id = sessionStorage.getItem("ntid");

    let data = publivAjax('/back/newType/findById', {id: id}, 'get');

    if (data != null)
    {
        let model = data.model;
        $("#typeName").val(model.typeName);
        $("#isShow").val(model.isShow);
        $("#recommend").val(model.recommend);
    }
}

function save()
{
    let msg = {}
    let id = sessionStorage.getItem("ntid");

    msg.id = id;
    msg.typeName = $.trim($("#typeName").val());
    msg.isShow = $.trim($("#isShow").val());
    msg.recommend = $.trim($("#recommend").val());

    let data = publivAjax('/back/newType/edit', msg, 'post');

    if (data.count == 1)
    {
        $('#b-right').load('/back/newType/newTypeList.html');
    }
    else
    {
        alert("修改失败！");
    }
}